package com.net.shop.car.manager;

import java.util.List;

import android.view.View;
import android.view.ViewGroup;

/**
 * @description 所有适配器应该继承到基类<br>
 *              仅需重写getView方法
 * @author wangpeng
 * @date 2014-12-20
 */
public abstract class BaseAdapter extends android.widget.BaseAdapter {

	private List<?> list;

	public BaseAdapter(List<?> list) {
		this.list = list;
	}

	@Override
	public int getCount() {
		return list != null ? list.size() : 0;
	}

	@Override
	public Object getItem(int position) {
		if (list != null && list.size() < position) {
			return list.get(position);
		}
		return null;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public abstract View getView(int position, View convertView, ViewGroup parent);
}
